package com.activity.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.activity.bean.PoiItemBean;
import com.amap.api.services.core.PoiItem;
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.adapter.BaseAdapter;

import androidx.annotation.NonNull;
import butterknife.BindView;

public class AddressChooseAdapter extends BaseAdapter<PoiItemBean> {



    public AddressChooseAdapter(Context context) {
        super(context);
    }




    @Override
    public boolean hasHeader(int groupPosition) {
        return false;
    }

    @Override
    public boolean hasFooter(int groupPosition) {
        return false;
    }

    @Override
    public int getHeaderLayout(int viewType) {
        return R.layout.header_address_choose;
    }


    @Override
    public BaseViewHolder<PoiItemBean> getViewHolder(int viewType, View view) {
        return new addressHolder(view);
    }

    @Override
    public int getChildLayout(int viewType) {
        return R.layout.item_address_choose_cell;
    }



    @Override
    public void onBindHeaderViewHolder(com.donkingliang.groupedadapter.holder.BaseViewHolder holder, int groupPosition) {


    }

    @Override
    public void onBindChildViewHolder(com.donkingliang.groupedadapter.holder.BaseViewHolder holder, int groupPosition, int childPosition) {
        super.onBindChildViewHolder(holder, groupPosition, childPosition);


    }

    public class addressHolder extends BaseViewHolder<PoiItemBean> {
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_address)
        TextView tvAddress;
        @BindView(R.id.iv_check)
        ImageView ivCheck;
        public addressHolder(@NonNull View itemView) {
            super(itemView);
        }

        @Override
        public void setData(PoiItemBean data) {

            tvName.setText(data.poiItem.getTitle());
            tvAddress.setText(data.poiItem.getSnippet());
            if(data.selected){
                ivCheck.setVisibility(View.VISIBLE);
            }else
            {
                ivCheck.setVisibility(View.GONE);
            }

        }
    }


}
